﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Globus.aspx.cs" Inherits="Continents_Task.Globus" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="formMain" runat="server">
    <asp:ListBox ID="ListBoxContinents" runat="server" DataSourceID="EntityDataSourceWorldLocations"
        DataTextField="ContinentName" DataValueField="ContinentID" 
        OnSelectedIndexChanged="ListBoxContinents_SelectedIndexChanged" 
        AutoPostBack="True">
    </asp:ListBox>
    <asp:GridView ID="GridViewCountries" runat="server" AllowPaging="True" 
        AllowSorting="True" DataKeyNames="CountryID" 
        DataSourceID="EntityDataSourceCountries">
        <Columns>
            <asp:CommandField ShowSelectButton="True" />
        </Columns>
       
    </asp:GridView>

    <asp:EntityDataSource ID="EntityDataSourceCountries" runat="server"
        ConnectionString="name=WorldLocationsEntities"
        DefaultContainerName="WorldLocationsEntities"         
        EntitySetName="Countries"
        Where="it.[ContinentID] == @contID">
        <WhereParameters>
            <asp:ControlParameter ControlID="ListBoxContinents" DefaultValue="0" Name="contID" Type="Int32"/>
        </WhereParameters>
    </asp:EntityDataSource>

    <asp:EntityDataSource ID="EntityDataSourceWorldLocations" runat="server" ConnectionString="name=WorldLocationsEntities"
        DefaultContainerName="WorldLocationsEntities" EnableFlattening="False" EntitySetName="Continents">
    </asp:EntityDataSource>
    <br />
    <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" 
        DataKeyNames="CityID" DataSourceID="asd" Height="50px" Width="125px">
        <Fields>
            <asp:BoundField DataField="CityID" HeaderText="CityID" ReadOnly="True" 
                SortExpression="CityID" />
            <asp:BoundField DataField="CityName" HeaderText="CityName" 
                SortExpression="CityName" />
            <asp:BoundField DataField="CountryID" HeaderText="CountryID" 
                SortExpression="CountryID" />
            <asp:BoundField DataField="Population" HeaderText="Population" 
                SortExpression="Population" />
        </Fields>
    </asp:DetailsView>
    <asp:EntityDataSource ID="asd" runat="server" 
        ConnectionString="name=WorldLocationsEntities" 
        DefaultContainerName="WorldLocationsEntities" EnableFlattening="False" 
        EntitySetName="Cities" Where="it.[CountryID] == @ctrID">
        <WhereParameters>
        <asp:ControlParameter Name="ctrID" ControlID="GridViewCountries" DefaultValue="0" Type="Int32" /></WhereParameters>
    </asp:EntityDataSource>
    </form>
</body>
</html>
